package Year21_Month11.day1121;

public class Soultion2 {
    public String reverseWords(String s) {
        String str = s.trim();

        String[] string = s.split(" ");

        StringBuilder sb = new StringBuilder();

        for(int i=string.length-1;i>=0;i--){
            if(string[i].equals(" ")||string[i].equals("")){
                continue;
            }

            sb.append(string[i]);
            sb.append(" ");

        }
        return sb.toString().trim();
    }
}
